package de.tum.in.eist.im.shared.PatternMatch;

public class PatternMatch {
	
	/**
	 * parse a json message to an array
	 * @param aMessage the json string of the message
	 * @return a string array including all 
	 */
   public static String[] parseJsonMessage(String aMessage) {    
       String pattern = "(\\{\\{\"[a-zA-Z]+\":\"|\"\\},\\s\\{\"[a-zA-z]+|\":\"|\"\\}\\})";
       String[] tokens = aMessage.split(pattern);
       String[] resultArray = new String[tokens.length/2];
       
       for (int i = 0; i < tokens.length; i++) {
           if(i % 2 == 1) {
               resultArray[i/2] = tokens[i];
           }
       }
       return resultArray;    
   }
}